<%-- 
    Document   : index
    Created on : Apr 21, 2012, 7:01:58 PM
    Author     : TANGQUOCTUAN
--%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Tunga Restaurant</title>
        <script type="text/javascript">
            function check(){
                var user = document.getElementById("user");
                var re = /^\w{6,20}$/;
                if(user.value.length==0){
                    alert("This field is required");
                    f.txtUserIf.focus();
                    return false;
                }

                if(re.test(user.value)==false){
                    alert("Username must be least at 6 - 20 character");
                    f.txtUserIf.focus();
                    return false;
                }

                var pass = document.getElementById("pass");
                if(pass.value.length==0){
                    alert("This field is required");
                    f.txtPassIf.focus();
                    return false;
                }

                if(re.test(pass.value)==false){
                    alert("Password must be least at 6 - 20 character");
                    f.txtPassIf.focus();
                    return false;
                }

                var re_name = /^\w[A-Za-z\s]*\w$/;
                var fname = document.getElementById("fname");
                if(fname.value.length==0){
                    alert("This field is required");
                    f.txtFnameIf.focus();
                    return false;
                }

                if(re_name.test(fname.value)==false){
                    alert("First name must be character");
                    f.txtFnameIf.focus();
                    return false;
                }

                var lname = document.getElementById("lname");
                if(lname.value.length==0){
                    alert("This field is required");
                    f.txtLnameIf.focus();
                    return false;
                }

                if(re_name.test(lname.value)==false){
                    alert("Last name must be character");
                    f.txtLnameIf.focus();
                    return false;
                }

                var re_email=/^[A-Za-z][A-Za-z0-9_.-]+@[A-Za-z]+\.[A-Za-z]{2,4}(\.[A-Za-z]{2,4})*$/;
                var email = document.getElementById("email");
                if(email.value.length==0){
                    alert("This field is required");
                    f.txtEmailIf.focus();
                    return false;
                }

                if(re_email.test(email.value)==false){
                    alert("Email must follow form xxx@xxx.xxx");
                    f.txtEmailIf.focus();
                    return false;
                }

                var resphone=/^[\d]{1,20}$/;
                var phone = document.getElementById("phone");
                if(phone.value.length==0){
                    alert("This field is required");
                    f.txtPhoneIf.focus();
                    return false;
                }

                if(resphone.test(phone.value)==false){
                    alert("Phone must be numberic, max 20 numberric");
                    f.txtPhoneIf.focus();
                    return false;
                }
                var re_address=/^\w[\w\s]+\w$/;
                var address = document.getElementById("address");
                if(address.value.length==0){
                    alert("This field is required");
                    f.txtAddressIf.focus();
                    return false;
                }
				
                if(re_address.test(address.value)==false){
                    alert("Address character only");
                    f.txtAddressIf.focus();
                    return false;
                }
                return true;
            }
        </script>
        <link href="style_admin.css" rel="stylesheet" type="text/css" />
    </head>
    <body>
        <center>
            <c:set var="session" value="${sessionScope.user}"/>
            <c:if test="${empty session}">
                <c:redirect url="index.jsp"/>
            </c:if>
            <div class="outer">
                <!--Header end-->
                <div id="rc1"></div>
                <div id="bg">
                    <div class="toplinks"><a href="ContactUs.jsp">Contact us</a></div><div class="sap">|</div>
                    <div class="toplinks"><a href="initShowFood?action=Food">Food</a></div><div class="sap">|</div>
                    <div class="toplinks"><a href="ControllerTables?action=Table">Table</a></div><div class="sap">|</div>
                    <div class="toplinks"><a href="ControllerRooms?action=Room">Room</a></div><div class="sap">|</div>
                    <c:if test="${empty session}">
                        <div class="toplinks"><a href="registration.jsp">Register</a></div><div class="sap">|</div>
                        <div class="toplinks"><a href="login.jsp">Login</a></div><div class="sap">|</div>
                    </c:if>
                    <div class="toplinks"><a href="index.jsp">Home Page</a></div>
                    <div><font color="white">Welcome, </font><font color="yellow">${sessionScope.user}</font> </div>
                    <div>
                        <font color="yellow"><a href="ControllerCustomer?action=Information&user=${sessionScope.user}">Your information</a></font>
                        <%
                                    if (session.getAttribute("isadmin") != null) {
                        %>
                        <a href="index_admin.jsp">Admin Manager</a>
                        <%                                    }
                        %>
                        <font color="yellow">
                            <c:url var="LogOut" value="ControllerCustomer">
                                <c:param name="action" value="LogOut"/>
                            </c:url>
                            <a href="${LogOut}">LogOut</a>
                        </font>
                    </div>
                </div>
                <div id="rc2"></div>
                <div id="header">
                    <div class="name">Tunga Restaurant Admin Manager</div>
                    <div class="tag">The best restaurant in the world</div>
                </div>
                <!--Top nav end-->
                <div style="clear:left"></div>
                <div id="outer2">
                    <div id="left-nav">
                        <div class="leftlinks">
                            <span class="heading">Manage</span>
                            <ul>
                                <li><a href="ControllerCustomer?action=Customer">Customer</a></li>
                                <li><a href="ControllerFood?action=adminFood">Food</a></li>
                                <li><a href="ControllerAdminRooms?action=AdminRooms">Room</a></li>
                                <li><a href="ControllerTables?action=AdminTables">Table</a></li>
                                <li><a href="ControllerOrderFood?action=adminOrderFood">Order Food</a></li>
                                <li><a href="ControllerAdminBookRooms?action=AdminBookRooms">Book Room</a></li>
                                <li><a href="ControllerTables?action=AdminBookTables">Book Table</a></li>
                                <li><a href="report.jsp">Report</a></li>
                            </ul>
                        </div>
                    </div><div class="inner_copy"><div class="inner_copy">All <a href="http://www.magentothemesworld.com" title="Best Magento Templates">premium Magento themes</a> at Magentothemesworld.com!</div></div>
                    <div id="content" align="center">
                        <span class="heading">Edit Customer Details </span>
                        <div id="main">
                            <c:set var="rows" value="${requestScope.info}"/>
                            <c:if test="${not empty rows}">
                                <div align="center">
                                    <form action="ControllerCustomer" method="POST" name="f" onsubmit="return check();">
                                        <table border="0" align="center">
                                            <tbody>
                                                <tr>
                                                    <td>UserName:</td>
                                                    <td><input type="text" name="txtUserIf" value="${rows.custID}" readonly="true" id="user"/></td>
                                                </tr>
                                                <tr>
                                                    <td>Password:</td>
                                                    <td><input type="password" name="txtPassIf" value="${rows.password}" id="pass"/></td>
                                                </tr>
                                                <tr>
                                                    <td>First Name:</td>
                                                    <td><input type="text" name="txtFnameIf" value="${rows.fname}" id="fname"/></td>
                                                </tr>
                                                <tr>
                                                    <td>Last Name:</td>
                                                    <td><input type="text" name="txtLnameIf" value="${rows.lname}" id="lname"/></td>
                                                </tr>
                                                <tr>
                                                    <td>Email:</td>
                                                    <td><input type="text" name="txtEmailIf" value="${rows.email}" id="email"/></td>
                                                </tr>
                                                <tr>
                                                    <td>Phone:</td>
                                                    <td><input type="text" name="txtPhoneIf" value="${rows.phone}" id="phone"/></td>
                                                </tr>
                                                <tr>
                                                    <td>Address:</td>
                                                    <td><textarea name="txtAddressIf" id="address" rows="10" cols="30">${rows.address}</textarea></td>
                                                </tr>
                                                <tr>
                                                    <td>Roles:</td>
                                                    <c:set var="role" value="${requestScope.role}"/>
                                                    <td><select name="drop">
                                                            <c:forEach var="roles" items="${role}">
                                                                <option value="${roles.roleId}"
                                                                        <c:if test="${roles.roleId == rows.roles.roleId}">selected</c:if>
                                                                        >${roles.roleName}</option>
                                                            </c:forEach>
                                                        </select>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td></td>
                                                    <td><input type="submit" value="Updates" name="action" /> <input type="button" value="Cancel" onclick="history.go(-1);"/></td>
                                                </tr>
                                            </tbody>
                                        </table>
                                    </form>
                                </div>
                            </c:if>
                        </div>
                    </div>
                    <div style="clear:left"></div>
                </div>
                <!--Bottom part-->
                <div id="bottom">
                    <div id="footer"><div class="fcenter">GROUP02-F5-10-1009-S1</div></div>
                </div>
            </div>
        </center>
    </body>
</html>
